package xxl.robotlegs.extensions.commandcenter.impl 
{
	import xxl.robotlegs.extensions.commandcenter.api.ICommandMapping;
	/**
	 * ...
	 * @author XXL
	 */
	public class CommandMapping implements ICommandMapping
	{
		private var _commandClass:Class;
		private var _executeMethod:String = "execute";
		private var _guards:Array = [];
		private var _hooks:Array = [];
		private var _fireOnce:Boolean;
		private var _payloadInjectionEnabled:Boolean = true;
		
		public function CommandMapping(commandClass:Class) 
		{
			_commandClass = commandClass;
		}
		
		public function toString():String
		{
			return "Command " + _commandClass;
		}
		
		/* INTERFACE xxl.robotlegs.extensions.commandcenter.api.ICommandMapping */
		
		public function get commandClass():Class 
		{
			return _commandClass;
		}
		
		public function get executeMethod():String 
		{
			return _executeMethod;
		}
		
		public function get guards():Array 
		{
			return _guards;
		}
		
		public function get hooks():Array 
		{
			return _hooks;
		}
		
		public function get fireOnce():Boolean 
		{
			return _fireOnce;
		}
		
		public function get payloadInjectionEnabled():Boolean 
		{
			return _payloadInjectionEnabled;
		}
		
		public function setExecuteMethod(name:String):ICommandMapping 
		{
			_executeMethod = name;
			return this;
		}
		
		public function addGuards(...guards):ICommandMapping 
		{
			_guards = _guards.concat(guards);
			//_guards = _guards.concat.apply(null, guards);
			return this;
		}
		
		public function addHooks(...hooks):ICommandMapping 
		{
			_hooks = _hooks.concat(hooks);
			//_hooks = _hooks.concat.apply(null, hooks);
			return this;
		}
		
		public function setFireOnce(value:Boolean):ICommandMapping 
		{
			_fireOnce = value;
			return this;
		}
		
		public function setPayloadInjectionEnabled(value:Boolean):ICommandMapping 
		{
			_payloadInjectionEnabled = value;
			return this;
		}
		
	}

}